<!--{subtemplate inc/header}-->
<script type="text/javascript">
<!--{dynamic getGoodsDynamics args=$goods['id']}-->
</script>
<script type="text/javascript" src="{PUBLIC_PATH}js/listtable.js"></script>
<div id="sysmsg-box">
	<div id="sysmsg-error" class="sysmsg{if $error == ''} hidden{/if}">
		<div><span class="fl">$error</span><span class="close">关闭</span></div>
	</div>
	<div id="sysmsg-success" class="sysmsg{if $success == ''} hidden{/if}">
		<div><span class="fl">$success</span><span class="close">关闭</span></div>
	</div>
</div>
<div class="blank9"></div>
<div class="hbox">
	<div id="body-left" class="fl">
		<div id="goods-show">
			<div class="box">
				<div class="title">
					<strong>$goods[site][name]</strong>
					<h1>$goods[name]</h1>
				</div>
				<div class="info" style="position:relative;">
					<div class="gs-img"><img src="$goods[small_img]" width="440" /></div>
					<div class="attrs">
						<div class="item">
							<p>$goods[city]</p>
							<div class="gs-time">
								<span class="time settime" endTime="$goods[end_time]">$goods[end_time_format]</span>
							</div>
						</div>
						<div class="gs-prices">
							<p>现价：<span>$goods[shop_price_format]</span></p>
							<p>原价：<b>$goods[market_price_format]</b></p>
							<p>折扣：<b>$goods[discount]</b>折</p>
						</div>
						<div class="gs-btns">
							<a href="$goods[go_url]" target="_blank"><img src="{TPL_PATH}images/s2.gif" /></a>
							<a style="margin:8px 0 0 0" href="javascript:;" id="goods-collect" rel="collectCount"><img src="{TPL_PATH}images/s5.gif" /></a>
						</div>
						<div class="item">
							<p>售出：<b><script type="text/javascript">document.write(goodsDynamics["g_{$goods['id']}"]["bought"]);</script></b></p>
							<p class="r">收藏：<b id="collectCount"><script type="text/javascript">document.write(goodsDynamics["g_{$goods['id']}"]["collect"]);</script></b></p>
						</div>
						<div class="item">
							<p>节省：<b>$goods[save_format]</b></p>
							<a href="#message" class="message">参加评论</a>
						</div>
					</div>
					<div class="blank9"></div>
				</div>
			</div>
		</div>
		<div class="blank9"></div>
		<div class="show-tabs">
			<div class="tabs-title">
				<a class="current" rel="message" href="javascript:;">团购评论</a>
				<!--{if !empty($goods['brief'])}-->
				<a rel="brief" href="javascript:;">团购提示</a>
				<!--{/if}-->
				<!--{if !empty($goods['content'])}-->
				<a rel="content" href="javascript:;">团购详细</a>
				<!--{/if}-->
			</div>
			<div class="tabs-body" id="tabs_body">
				<div id="messagebox" class="tb-item current" rel="message">
					<div class="list" id="goods_comment_list"></div>
					<div class="blank20"></div>
					<div class="add">
						<!--{dynamic getCommentForm args=0}-->
					</div>
					<div class="blank12"></div>
				</div>
				<!--{if !empty($goods['brief'])}-->
				<div class="tb-item tb-content" rel="brief">
					$goods['brief']
				</div>
				<!--{/if}-->
				<!--{if !empty($goods['content'])}-->
				<div class="tb-item tb-content" rel="content">
					$goods['content']
				</div>
				<!--{/if}--><strong></strong>
			</div>
		</div>
	</div>
	<div id="body-right" class="fr"> 
	<!--{subtemplate inc/common/right}-->
	</div>
</div>
<script type="text/javascript">
var goodsID = $goods[id];
var goodsName = "$goods[name]";
var commentLT;

jQuery(function($){
	commentLT = new ListTable();
	commentLT.url = SITE_PATH + "/services/ajax.php?action=get_goods_comment";
	commentLT.filter.rec_id = goodsID;
	commentLT.filter.pageSize = 10;
	commentLT.filter.LT = 'commentLT';
	commentLT.resultFun = getCommentListResult;
	commentLT.loadFun = getCommentListLoading;
	
	$("#comment-add-form").submit(function(){
		if($.trim($("#content").val()).length == 0)
		{
			$.showErr("请填写评论内容");
			$("#content").focus();
			return false;
		}
		
		var query = new Object();
		query.rec_id = goodsID;
		query.rec_name = goodsName;
		query.content = $.trim($("#content").val());
		query.isajax = 1;
		query.action = "add_goods_comment";
		
		$.showLoading("#tabs_body");
		
		$.ajax({
			type: "POST",
			dataType: "json",
			cache:false,
			url: SITE_PATH + "/services/ajax.php",
			data:query,
			success: function(data){
				if(data.status == 1)
				{
					commentLT.GotoPage(1);
				}
				else
				{
					alert(data.msg);
					$.closeLoading("#tabs_body");
				}
			}
		});
		
		return false;
	});
	
	commentLT.GotoPage(1);
	
	$(".tabs-title a").click(function(){
		$(".tabs-title a").removeClass('current');
		$(this).addClass('current');
		$(".tb-item").removeClass('current');
		$(".tb-item[rel='"+this.getAttribute('rel')+"']").addClass('current');
	});
	
	$("#goods-collect").click(function(){
		var query = new Object();
		query.goods_id = goodsID;
		query.goods_name = goodsName;
		query.action = "goods_handler";
		query.type = 'GOODS_COLLECT';
		var rel = this.getAttribute("rel");
		$.showLoading("#goods-show .info");
		$.ajax({
			url: SITE_PATH + "/services/ajax.php",
			data: query,
			dataType:"json",
			cache:false,
			success:function(data){
				$.closeLoading("#goods-show .info");
				if(data.status == 1)
				{
					$.showSuccess("收藏团购成功");
					$("#"+rel).html(goodsDynamics["g_{$goods['id']}"]["collect"] + 1);
				}
				else if(data.status == 2)
				{
					$.showErr("你已经收藏过此团购");
				}
				else if(data.status == 3)
				{
					$.showErr('请先&nbsp;<a target="_blank" href="{u user/login}" style="color:#690;">登陆</a>&nbsp;或&nbsp;<a target="_blank" href="{u user/reg}" style="color:#690;">注册</a>!');
				}
			}
		});
		
	});
});

function getCommentListResult(data)
{
	$.closeLoading("#tabs_body");
	$("#goods_comment_list").html(data.html);
}

function getCommentListLoading(data)
{
	$.showLoading("#tabs_body");
}
</script>
<!--{subtemplate inc/footer}-->